#ifndef __BTREE_H__
#define __BTREE_H__

struct node {
	struct node *left, *right;
	char data[0];
};

typedef struct {
	struct node *root;
	int size;
}tree_t;

typedef int (*cmp_t)(const void *data, const void *key);
typedef void (*pri_t)(const void *data);

extern int tree_init(tree_t **mytree, int size);
extern int tree_insert(tree_t *mytree, const void *data, cmp_t cmp);
extern int tree_delete(tree_t *mytree, const void *key, cmp_t cmp);
extern void *tree_find(const tree_t *mytree, const void *key, cmp_t cmp);
extern void tree_traval_mid(const tree_t *mytree, pri_t pri);
extern void tree_destroy(tree_t **mytree);

#endif

